<?php
/*
 * 网站设置
 */
namespace app\admin\controller;
use think\Db;
class Setting extends Comm
{
   public function setting()
    {

        $vars = Db::name('setting')->where('type=1')->select();
        $this->assign('vars', $vars);

        return $this->fetch();
    }
	
	
	//提交设置
    public function update()
    {
        $data = $_POST;
        $data['sitename'] = isset($_POST['sitename']) ? strip_tags($_POST['sitename']) : '';
        $data['title'] = isset($_POST['title']) ? strip_tags($_POST['title']) : '';
        $data['keywords'] = isset($_POST['keywords']) ? strip_tags($_POST['keywords']) : '';
        $data['description'] = isset($_POST['description']) ? strip_tags($_POST['description']) : '';
        $data['footer'] = isset($_POST['footer']) ? $_POST['footer'] : '';
       // $Model = Db::name('setting');
        foreach ($data as $k => $v) {
            Db::name('setting')->where("k='{$k}'")->update(array('v' => $v));
        }
        cache(NULL);
        addlog('修改网站配置。');
        //$this->success('恭喜，网站配置成功！');
		return json(array('code' => 200, 'msg' => '恭喜，网站配置成功！'));
    }
}
?>